*** This replicates all Figures (1, 2, A1, A2) as well as tables A3, A4, and A7

use "/Users/eporter/Dropbox/Iowa Teachers Union Experiment/Persuasion test/Replication/main_survey.dta", clear

** Run regressions for analysis

* Full sample, no covariates

foreach var of varlist cb_support_index tax_support_index net_sts_avg cutindex supportstrikes_nodk megaindex megaindex_nostrike{
	reg std_`var' treatment_1 treatment_2 treatment_3 treatment_4, rob 
	estimates store `var'_full
	reg std_`var' treat_vidonly treat_pers, rob
	estimates store `var'_mode
	reg std_`var' treat_contracts treat_community , rob
	estimates store `var'_theme
}  

* Full sample, covariates

global covariates i.parentbin i.educ3 i.inc_quartiles i.age_terciles i.white i.anymem i.knowanyunionmem i.knowanyteacher i.ideo3 i.party3

foreach var of varlist cb_support_index tax_support_index net_sts_avg cutindex supportstrikes_nodk megaindex megaindex_nostrike{
	reg std_`var' treatment_1 treatment_2 treatment_3 treatment_4 $covariates, rob 
	estimates store `var'_fullc
	reg std_`var' treat_vidonly treat_pers $covariates, rob
	estimates store `var'_modec
	reg std_`var' treat_contracts treat_community $covariates, rob
	estimates store `var'_themec
}  

* Non-Midwest sample

foreach var of varlist cb_support_index tax_support_index net_sts_avg cutindex supportstrikes_nodk megaindex megaindex_nostrike{
	reg `var' treatment_1 treatment_2 treatment_3 treatment_4 if group=="national", rob
	estimates store `var'_full_n
	reg `var' treat_vidonly treat_pers if group=="national", rob
	estimates store `var'_mode_n
	reg `var' treat_contracts treat_community if group=="national", rob
	estimates store `var'_theme_n
}  

* Create Table A3

estout cb_support_index_full tax_support_index_full net_sts_avg_full cutindex_full megaindex_nostrike_full using table_a3.tex, label cells(b(star fmt(2)) se(par fmt(2))) legend drop(_cons) stats(r2 N) starlevels(* 0.10 ** 0.05 *** 0.01) replace nobaselevels

* Create Table A4

estout cb_support_index_mode tax_support_index_mode net_sts_avg_mode cutindex_mode megaindex_nostrike_mode using table_a4.tex, label cells(b(star fmt(2)) se(par fmt(2))) legend drop(_cons) stats(r2 N) starlevels(* 0.10 ** 0.05 *** 0.01) replace nobaselevels

* Create Table A7

estout cb_support_index_theme tax_support_index_theme net_sts_avg_theme cutindex_theme megaindex_nostrike_theme using table_a7.tex, label cells(b(star fmt(2)) se(par fmt(2))) legend drop(_cons) stats(r2 N) starlevels(* 0.10 ** 0.05 *** 0.01) replace nobaselevels

* Create Figure 1

#delimit ;
coefplot cb_support_index_full tax_support_index_full net_sts_avg_full cutindex_full, 
drop(_cons) xline(0, lpattern(dash)) 
aseq swapnames legend(off) nooffset scheme(s1mono) 
coeflabel(
cb_support_index_full="Collective Bargaining Support Index"
tax_support_index_full="Support for Raising Taxes for Education Index"
net_sts_avg_full="Perceptions of Teachers Unions Index"
cutindex_full="Support for Anti-Union Measures Index"
)
xtitle("OLS Coefficient")
mcolor(black) lcolor(black) mlcolor(black) mfcolor(black)
ciopts(color(black)) msymbol(O)  note("Full Sample. Outcomes Standardized. Robust SEs.", span)
eqlabels(`""{it:Community,}" "{it:Narrative &}" "{it:Perspectives}""'
`""{it:Community,}" "{it:Narrative}""'
`""{it:Contracts,}" "{it:Narrative &}" "{it:Perspectives}""'
`""{it:Contracts,}" "{it:Narrative}""')
;
#delimit cr 
graph export "figure_1.pdf",replace
graph close

* Create Figure 2

coefplot megaindex_nostrike_mode, xline(0, lpattern(dash)) drop(_cons) title("Effect of Treatment Mode on Master Teacher Union Attitude Support Index", span) note("Full Sample. Outcome Standardized. Robust SEs.") xtitle(OLS Coefficient on Treatment) mlabel format(%9.2g) mlabposition(12) mlabgap(*2)
graph export "figure_2.pdf",replace
graph close

* Create Figure A1

#delimit ;
coefplot cb_support_index_fullc tax_support_index_fullc net_sts_avg_fullc cutindex_fullc, 
drop(_cons) xline(0, lpattern(dash)) 
keep(treatment_1 treatment_2 treatment_3 treatment_4)
aseq swapnames legend(off) nooffset scheme(s1mono) 
coeflabel(
cb_support_index_fullc="Collective Bargaining Support Index"
tax_support_index_fullc="Support for Raising Taxes for Education Index"
net_sts_avg_fullc="Perceptions of Teachers Unions Index"
cutindex_fullc="Support for Anti-Union Measures Index"
)
xtitle("OLS Coefficient")
mcolor(black) lcolor(black) mlcolor(black) mfcolor(black)
ciopts(color(black)) msymbol(O)  note("Full Sample. Outcomes Standardized. Robust SEs. Covariates included.", span)
eqlabels(`""{it:Community,}" "{it:Narrative &}" "{it:Perspectives}""'
`""{it:Community,}" "{it:Narrative}""'
`""{it:Contracts,}" "{it:Narrative &}" "{it:Perspectives}""'
`""{it:Contracts,}" "{it:Narrative}""')
;
#delimit cr 
graph export "figure_a1.pdf",replace
graph close

* Create Figure A2

#delimit ;
coefplot cb_support_index_full_n tax_support_index_full_n net_sts_avg_full_n cutindex_full_n, 
drop(_cons) xline(0, lpattern(dash)) 
aseq swapnames legend(off) nooffset scheme(s1mono) 
coeflabel(
cb_support_index_full_n="Collective Bargaining Support Index"
tax_support_index_full_n="Support for Raising Taxes for Education Index"
net_sts_avg_full_n="Perceptions of Teachers Unions Index"
cutindex_full_n="Support for Anti-Union Measures Index"
)
xtitle("OLS Coefficient")
mcolor(black) lcolor(black) mlcolor(black) mfcolor(black)
ciopts(color(black)) msymbol(O)  note("Non-Midwest sample. Outcomes Standardized. Robust SEs.", span)
eqlabels(`""Community," "Narrative &" "Perspectives""'
`""Community," "Narrative""'
`""Contracts," "Narrative &" "Perspectives""'
`""Contracts," "Narrative""')
;
#delimit cr 
graph export "figure_a2.pdf",replace
graph close
